/*
 * @Author: your name
 * @Date: 2021-10-12 16:45:02
 * @LastEditTime: 2021-10-12 22:44:25
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \实训二项目前端\myapp\src\router\RouterVIew.js
 */
import { Switch, Redirect, Route } from "react-router-dom";
import React from "react";
import BeforeEach from "../Router/BeforEach";
import "../App.css"

function RouterView(props) {
    const { routes } = props;
    return (
        <Switch>
            {routes.length &&
                routes.map((item, idx) => {
                    return item.path ? (
                        <Route
                            key={item.path}
                            path={item.path}
                            render={(props) => <BeforeEach {...props} {...item} />}
                        />
                    ) : (
                            <Redirect key={item.to} {...item} exact />
                        );
                })}
        </Switch>
    );
}

export default RouterView;